package com.attendance.sz.utils;



import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;

import com.attendance.sz.R;



public class SelfDefineLoadingDialog {

	//public static AlertDialog  currentAlertDialog;
	public static Dialog  currentAlertDialog;
	
	public static Dialog GetCurrentAlertDialog(Context context,View view,WindowManager manager,int[] layout)
	{	
	   LayoutParams lp;
       if(layout==null)
       {
    	   lp=new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
       }
       else
       {
    	   lp=new LinearLayout.LayoutParams(layout[0],layout[1]); 
       }
		
		Dialog dlg = new Dialog(context,R.style.CustomDialogStyle);
		dlg.show();
		Window window = dlg.getWindow();
		window.setBackgroundDrawable(new ColorDrawable(0));  
		window.setContentView(view,lp);
       return dlg;
	}
		    
	   
	public static void PopupLoadingDialog(final Context context,int resourceView,WindowManager manager
			,int[] layout)
	{
		View layoutView =(LinearLayout) LayoutInflater
					.from(context).inflate(resourceView, null);
		    
	    currentAlertDialog=GetCurrentAlertDialog(context,layoutView,manager,layout);
	}
	
	
	public static void CloseCurrentAlertDialog()
	{
		if(currentAlertDialog!=null)
		{
			currentAlertDialog.dismiss();
		}
	}
}
